export const http = function (http){
    console.log('inner', typeof http)
    if (typeof http !== 'function') {
      throw Error('传入的对象不是一个函数')
      return
    }
    var myHttp = {
      get: function (url, data, config) {
        config = config || {}
        let totalConfig = Object.assign({
          method: 'get',
          url: url,
          params: data
        }, config)
        return new Promise((resolve, reject) => {
          http(totalConfig).then((res) => {
            resolve(res)     //成功后的回调函数
          }, (err) => {
            reject(err)
          })
        })
      },
      post: function (url, data, config) {
        config = config || {}
        let totalConfig
        totalConfig = Object.assign({
          method: 'post',
          url: url,
          data: data
        }, config)
        return new Promise((resolve, reject) => {
          http(totalConfig).then((res) => {
            resolve(res)
          }, (err) => {
            reject(err)
          })
        })
      },
      put: function (url, data, config) {
        config = config || {}
        let totalConfig = Object.assign({
          method: 'put',
          url: url,
          data: data
        }, config)
        return new Promise((resolve, reject) => {
          http(totalConfig).then((res) => {
            resolve(res)
          }, (err) => {
            reject(err)
          })
        })
      },
      delete: function (url, data, config) {
        config = config || {}
        let totalConfig = Object.assign({
          method: 'delete',
          url: url,
          data: data
        }, config)
        return new Promise((resolve, reject) => {
          http(totalConfig).then((res) => {
            resolve(res)
          }, (err) => {
            reject(err)
          })
        })
      },
    }
    return myHttp
  }